const request = require('request');
var req = require("../../utils/router");
const db = require("../../mysql/index.js");
const config = require("./config.js");
let { router, GetRouter, PostRouter } = req

// 首页banner设置
new PostRouter().send("/home/setHome", function (res, data) {
    let { title, QRCode, bgImg, list } = data
    let obj = {
        'h_title': title,
        'h_bgImg': bgImg,
        'h_QRCode': QRCode,
        'h_list': JSON.stringify(list || [])
    }
    let sql = `${db.update(obj, "wh_home")} WHERE id=1`
    db.query(sql, (rows, fields) => {
        res.send({ code: 200, data: {} });
    })
})

new GetRouter().send("/home/getHome", function (res, data) {
    db.select({
        ...config
    }, (rows) => {
        res.send({
            code: 200,
            data: rows.list[0]
        })
    })
})
module.exports = router